package main

import (
	"flag"
	"log"
	"net/http"
	"os"
	"time"
)

var arg string

func init() {
	flag.StringVar(&arg, "arg", "", "设置参数 arg")
}

func main() {
	flag.Parse()

	go func() {
		for {
			log.Println("获取程序参数 -arg = " + arg)
			log.Println("获取环境变量 MY_DOCKER = " + os.Getenv("MY_DOCKER"))
			file, _ := os.ReadFile("/data/docker.text")
			log.Println("获取文件内容 /data/docker.text = " + string(file))
			time.Sleep(5 * time.Second)
		}
	}()
	http.HandleFunc("/docker", func(writer http.ResponseWriter, request *http.Request) {
		writer.Write([]byte("hello docker"))
	})
	http.ListenAndServe("0.0.0.0:5678", nil)
}
